/*
 * IGEntity.java
 * Created on 6 nov. 2008
 *
 * Glacéo Internet Platform
 * http://sourceforge.net/projects/chm/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hockeo.vhbase.data.dao;

import java.io.Serializable;

/**
 * Common interface that must be implemented by all persistent Glacéo classes.
 *
 * @version $Id$
 * @author jjanke
 */
public interface IGEntity extends Serializable
{
  /**
   * <p>
   * Proxy-safe check method allowing to verify if an IGEntity is an instance of a given
   * {@link IGEntity} class. Checks whether this class is an instance of the class
   * provided as an argument.
   * </p>
   *
   * <p>
   * Normal <code>instanceof</code> operations should be avoided on persistent Glacéo
   * classes because the instances may actually be proxied objects from the underlying
   * persistence engine. This method provides a safe way to check if this object is
   * assignable from the object provided as argument.
   * </p>
   *
   * @param classOther the class for which it should be checked whether this class is an
   *          instance of
   * @return <code>true</code> if this class is an instance of the given class
   */
  public boolean instanceOf( Class<? extends IGEntity> classOther );

  /**
   * Returns the class object behind this persistent instance. This method must be used to retrieve
   * a {@link Class} object because the method {@link #getClass()} may not return the actual class
   * in the case that the persistent instance is proxied. This method is proxy-safe!
   *
   * @return the actual Class behind this persistent object
   */
  public Class<? extends IGEntity> getGEntityClass();
}
